package com.cn.wanxi.servlet.nav;

import com.alibaba.fastjson.JSONObject;
import com.cn.wanxi.model.NavModel;
import com.cn.wanxi.model.ResultModel;
import com.cn.wanxi.service.NavService;
import com.cn.wanxi.service.impl.NavServiceImpl;
import com.cn.wanxi.util.Tool;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 更新用post，查询用get
 */
@WebServlet("/back/nav/findById")
public class NavFindByIdServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {


//        拿到前端的数据
        String id = req.getParameter("id");

        NavModel navModel = new NavModel();

        navModel.setId(Tool.strToInt(id));

        NavService navService = new NavServiceImpl();
      ResultModel resultModel= navService.findById(navModel);
        //6.返回给前端
        resp.getWriter().println(JSONObject.toJSONString(resultModel));
// 以后参数最好全部传递对象
//        List<NavModel> list = navService.getNavModelList(navModel, pageModel);

//        int count = navService.add(navModel);
    }


}
